<?php

use Illuminate\Database\Seeder;

class RolePermissionSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        // roles
        $adminRole = new \App\Models\Role(['name' => 'admin', 'display_name' => '管理员']);
        $adminRole->save();
        $motivatorRole = new \App\Models\Role(['name' => 'motivator', 'display_name' => '教练员']);
        $motivatorRole->save();
        $operatorRole = new \App\Models\Role(['name' => 'operator', 'display_name' => '操作员']);
        $operatorRole->save();

        // permission

        $paymentPermission = new \App\Models\Permission(['name' => 'create_payment', 'display_name' => '创建账单']);
        $paymentPermission->save();
        $programPermission = new \App\Models\Permission(['name' => 'create_program', 'display_name' => '创建课程']);
        $programPermission->save();
        $wechatPermission = new \App\Models\Permission(['name' => 'edit_wechat', 'display_name' => '修改微信用户信息']);
        $wechatPermission->save();

        $adminRole->attachPermissions(array($paymentPermission, $programPermission, $wechatPermission));

    }
}
